<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Business extends Model
{
    //
    protected $table = 'business';
    protected static $baseImg = 'https://winesh.oss-cn-beijing.aliyuncs.com/';
    protected $guarded = [];

    public function getCoverImgAttribute($val)
    {
        return get_full_img($val);
    }

    public function setPicsAttribute($pictures)
    {
        if (is_array($pictures)) {
            $pictures = array_map('get_full_img', $pictures);
            $this->attributes['pics'] = json_encode($pictures);
        }
    }

    public function getPicsAttribute($pictures)
    {
        if ($pictures) {
            return json_decode($pictures, true);
        } else {
            return $pictures;
        }

    }
}
